package cn.edu.cqupt.service.impl;

import cn.edu.cqupt.dao.UserDao;
import cn.edu.cqupt.po.User;
import cn.edu.cqupt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserDao userDao;


    @Override
    public Boolean add(User user) {
        int count = userDao.insert(user);
        return count == 1;
    }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public Boolean remove(int id) {
        int count = userDao.delete(id);
        return count == 1;
    }

    @Override
    public Boolean changeUser(User user) {
        int count = userDao.update(user);
        return count == 1;
    }

    @Override
    public User search(User user) {
        return userDao.select(user);
    }
}
